package Lee_code;

import java.util.Stack;

public class Lee_1047 {


    public String removeDuplicates(String s) {
        StringBuilder sb = new StringBuilder();
        char[] in = s.toCharArray();

        for(int i=0; i<s.length(); i++)
        {
            if(sb.length()==0)
            {
                sb.append(in[i]);
            }
            else
            {
                char temp = sb.charAt(sb.length());
                if(temp==in[i])
                {
                    sb.deleteCharAt(sb.length());
                }
                else
                {
                    sb.append(in[i]);
                }
            }
        }
        return sb.toString();
    }
}
